﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain;
using IntelligentAgriculture.WebAPI.Application.Command.DepartMentCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.DepartMentCommandHandler
{
    public class DepartMentMenuCommandHandler : IRequestHandler<DepartMentMenuCommand, Results<List<MenuList>>>
    {


        private readonly IDepartMentService departService;
        private readonly ILogger<DepartMentMenuCommandHandler> logger;
        public DepartMentMenuCommandHandler(IDepartMentService departService, ILogger<DepartMentMenuCommandHandler> logger)
        {
            this.departService = departService;
            this.logger = logger;
        }
        /// <summary>
        /// 树形
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<List<MenuList>>> Handle(DepartMentMenuCommand request, CancellationToken cancellationToken)
        {
            var list=await departService.MenuLIst(request.Pid);
            var results = Results<List<MenuList>>.DataResult(list);
            return results;
            
        }




    }





}
